package com.example.vae.Adapter;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
import androidx.fragment.app.FragmentStatePagerAdapter;

import java.util.List;

//这个是 Home页面进行的页面切换
public class MyFragmentPageAdapter extends FragmentStatePagerAdapter {

    List<Fragment>  list;
    String [] titles;

    @Nullable
    @Override
    public CharSequence getPageTitle(int position) {

        return titles[position];
    }

    public MyFragmentPageAdapter(@NonNull FragmentManager fm, int behavior) {
        super(fm, behavior);
    }

    public MyFragmentPageAdapter(@NonNull FragmentManager fm, int behavior,List<Fragment> list,String [] titles) {
        super(fm, behavior);
        this.list=list;
        this.titles=titles;
    }
    @NonNull
    @Override
    public Fragment getItem(int position) {
        return list.get(position);
    }

    @Override
    public int getCount() {
        return list.size();
    }
}
